<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <link rel="stylesheet" type="text/css" href="../../css/common.css">
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #f7911b;">
        <span class="aui-iconfont aui-icon-left aui-pull-left" onclick="api.closeWin()"></span>
        <!-- <span class="aui-iconfont aui-icon-left aui-pull-left" onclick="api.closeFrame();"></span> -->
        <div class="aui-title">绑定支付宝</div>
    </header>
    <div class="aui-content aui-margin-b-15">
        <div class="content">
            <div class="content-left">您的手机号：</div>
            <div class="content-right"><input type="text" id="mobile" style="cursor:not-allowed" disabled="disabled"></div>
        </div>
        <div class="content">
            <div class="content-left">支付宝账号：</div>
            <div class="content-right" ><input onkeyup="value=value.replace(/[^\d]/g,'') "type="text"   placeholder="请输入支付宝账号" id="payNum" ></div>
        </div>
        <div class="content">
            <div class="content-left">真实的姓名：</div>
            <div class="content-right"><input type="text" placeholder="请输入您的姓名" id="username"></div>
        </div>
    </div>
    <p>
        <div class="aui-btn aui-btn-danger aui-btn-block aui-margin-t-15"id="sub" onclick="submit();">提交</div>
    </p>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
    apiready = function() {

        var payNum = $api.byId('payNum');
        var username = $api.byId('username');
        var mobile = $api.byId('mobile');
        var sub = $api.byId('sub');
        mobile.value = $api.getStorage('userdata').mobile;
        


        // window.openapply = function() {
               
        //        api.openWin({
        //        name: 'apply',
        //        url: '../mine/zhifubao.html',
        //        rect: {
        //            x: 0,
        //            y: 0,
        //            w: 'auto',
        //            h: 'auto'
        //        },
        //        pageParam: {
        //            token: $api.getStorage('token')
        //        },
        //        allowEdit: true
        //    });
                  
        //        }


       

        window.submit = function() {



            var token = $api.getStorage('token');
            var body = {
                token: token,
                payNum: payNum.value,
                username: username.value,
                mobile: mobile.value
            };
if(payNum.value.length >= 10){
            if (payNum.value != '' && username.value != '' && mobile.value != '' && token!='' ) {
                api.ajax({
                    url: 'http://www.mk517.com/webApi/bindzhifubao.php',
                    method: 'post',
                    "headers": {
                        "Content-Type": "application/json"
                    },
                    dataType: 'json',
                    data: {
                        body: body
                    }
                }, function(ret, err) {

                 
                    if (ret) {
                      
                        if (ret.code==1) {
                            api.alert({
                                msg: ret.res,
                            }, function(ret, err) {
                              if(ret.buttonIndex==1){
                                api.closeFrame();
                              }
                            });
                        } else if(ret.code==-1){
                            api.alert({
                                msg:ret.res,
                            }, function(ret, err) {

                            });
                        }
                    } else {
                        api.alert({
                            msg: '服务器错误',
                        }, function(ret, err) {

                        });

                    }
                });
                api.sendEvent({
    name: 'myEvent',
    extra: {
        key1: 'value1',
        key2: 'value2'
    }
});
                api.closeWin();
               
            }else{
                alert('信息未完善');
                
            }
           
        }else{
            alert('支付宝账号不小于11位');
        }
    }
}
</script>

</html>
